package com.lil.qmui.ui.base;


import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;

import com.lil.qmui.R;
import com.lil.qmui.view.TitleBarView;


/**
 * 自带titleView的activity，集中处理titleView的事件
 *
 * @author zhazb
 */
public class TitleViewActivity extends BaseActivity {

    private TitleBarView titleView;

    @Override
    public void init() {

    }

    @Override
    public void data() {

    }

    public void initTitleView() {
        titleView = (TitleBarView) findViewById(R.id.title_view);
    }

    public void initLeftBackView(String content) {
        if (!TextUtils.isEmpty(content)) {
            titleView.setLeftViewContont(content);
        }
        titleView.setLeftViewOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    /**
     * 设置左侧view显示图片是X，默认是返回
     *
     * @param isShown
     */
    public void setLeftClosedView(boolean isShown) {
        if (isShown) {
            titleView.setLeftClosedView();
        }
    }

    public void setLeftViewBackground(int rID) {
        titleView.setLeftViewBackground(rID);
    }

    public void setLeftViewOnClickListener(OnClickListener listener) {
        titleView.setLeftViewOnClickListener(listener);
    }

    public void setLeftBackViewVisible(boolean isShown) {
        titleView.setLeftViewVisible(isShown);
    }


    public void setCenterViewContent(String content) {
        titleView.setCenterViewContent(content);
    }

    public void initRightView(String content) {
        if (!TextUtils.isEmpty(content)) {
            titleView.setRightViewContent(content);
        }
    }

    /**
     * 右侧按钮是否可见
     *
     * @param visible
     */
    public void setRightViewVisible(boolean visible) {
        titleView.setRightViewVisible(visible);
    }

    public void setRightViewEnable(boolean enable) {
        titleView.setRightViewEnable(enable);
    }

    public void setRightViewOnClickListener(OnClickListener listener) {
        titleView.setRightViewOnClickListener(listener);
    }

    /**
     * 标题栏是否可见
     */
    public void setTitleVisibility(boolean visibility) {
        titleView.setTitleVisibility(visibility);
    }
}
